package myky.com.doctorapp.model

import com.xiangyao.train.utils.RxScedulerHelper
import io.reactivex.Observable
import myky.com.doctorapp.api.ApiManager
import myky.com.doctorapp.base.BaseEntity
import myky.com.doctorapp.contract.FindDoctorContract
import myky.com.doctorapp.entity.DepatmentWrapperEntity
import myky.com.doctorapp.entity.DoctorWrapperEntity
import myky.com.doctorapp.utils.RequestBodyBuilder

class FindDoctorModel : FindDoctorContract.Model {
    override fun findDoctorList(version: String, customerId: String, size: Int, current: Int, type: String): Observable<BaseEntity<DoctorWrapperEntity.DoctorListEntity>> {
        val requestBodyBuilder = RequestBodyBuilder.Builder()
        val build = requestBodyBuilder.params("version", version)
                .params("customerId", customerId)
                .params("size", size.toString())
                .params("current", current.toString())
                .params("type", 1.toString()).build()

        return ApiManager.getApistore().findDoctorList(build).compose(RxScedulerHelper.io_main())


    }

    override fun findDepartMent(): Observable<BaseEntity<DepatmentWrapperEntity.Depatment>> {
        val requestBodyBuilder = RequestBodyBuilder.Builder()
        requestBodyBuilder.params("version", "v2.0")
        val requestBody = requestBodyBuilder.build()
        return ApiManager.getApistore().findDepartMent(requestBody).compose(RxScedulerHelper.io_main())
    }
}
